package com.ydd.controller.admin;

import com.ydd.dto.SysUserLoginDTO;
import com.ydd.result.Result;
import com.ydd.service.LoginService;
import com.ydd.service.SysConfigService;
import com.ydd.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/index")
@Slf4j
public class LoginController {

    @Autowired
    SysConfigService sysConfigService;

    @Autowired(required = false)
    SysUserService sysUserService;

    @Autowired(required = false)
    LoginService loginService;

    /**
     * 获取系统配置
     * @return
     */
    @GetMapping("/getConfig")
    public Result getConfig(){
        log.info("获取系统配置");
        return sysConfigService.getConfig();
    }


    /**
     * 登录接口
     * @param dto
     * @return
     */
    @PostMapping("/login")
    public Result login(@RequestBody SysUserLoginDTO dto){
        log.info("获取系统配置");
        return sysUserService.login(dto);
    }

    /**
     * 获取用户资料
     * @return
     */
    @PostMapping("/profile")
    public Result profile(){
        log.info("获取用户资料");
        return loginService.profile();
    }

    /**
     * 主页统计信息
     * @return
     */
    @GetMapping("/baseInfo")
    public Result baseInfo(){
        log.info("主页统计信息");
        return loginService.baseInfo();
    }

}
